<?php
/**
 * Created by PhpStorm.
 * User: CCJK
 * Date: 2018/4/19
 * Time: 15:51
 * 数据库:
 * http://www.symfonychina.com/doc/current/doctrine.html
 * 1.配置数据库 pdo_mysql 或者 pdo_sqlite 或者其他
 * 2. php bin/console doctrine:database:create 创建数据库
 * 3.创建实体类,例如Product
 *      a:可以直接编写代码,setter getter不用写
 *      b:也可以 用命令交互的方式创建php bin/console doctrine:generate:entity
 * 4.生成getter 和setter
 *          php bin/console doctrine:generate:entities AppBundle/Entity/Product 生成一个
 *          php bin/console doctrine:generate:entities AppBundle 生成所有
 * 5.创建表 php bin/console doctrine:schema:update --force 例如product表
 * 6.php bin/console doctrine:schema:validate 检查是否正确
 *
 *
 */
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="product")
 */
class Product
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=100 )
     */
    private $name;

    /**
     * @ORM\Column(type="decimal", scale=2)
     */
    private $price;

    /**
     * @ORM\Column(type="text")
     */
    private $description;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     *
     * @return Product
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set price
     *
     * @param string $price
     *
     * @return Product
     */
    public function setPrice($price)
    {
        $this->price = $price;

        return $this;
    }

    /**
     * Get price
     *
     * @return string
     */
    public function getPrice()
    {
        return $this->price;
    }

    /**
     * Set description
     *
     * @param string $description
     *
     * @return Product
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    public function __toString()
    {
        return "id: ".$this->id." ; name: ".$this->name." ; price: ".$this->price;
    }
}
